﻿using AiChiTu.TraceabilitySystem.Domain.AiChiTuManagement;
using AiChiTu.TraceabilitySystem.Domain.RBAC;
using AiChiTu.TraceabilitySystem.Domain.TestEntity;
using Microsoft.EntityFrameworkCore;

namespace AiChiTu.TraceabilitySystem.Infrastructure
{
	/// <summary>
	/// 数据库上下文
	/// </summary>
	public class DataDBContext : DbContext
	{
		/// <summary>
		/// 构造方法
		/// :base	调用的父类构造函数
		/// </summary>
		/// <param name="options">选项</param>
		public DataDBContext(DbContextOptions<DataDBContext> options) : base(options)
		{
		}
		/// <summary>
		/// 模型创建
		/// </summary>
		/// <param name="modelBuilder">模型创建器</param>
		protected override void OnModelCreating(ModelBuilder modelBuilder)
		{
			// 给实体添加表名
			modelBuilder.Entity<TestInfo>().ToTable("TestInfos");
			// 给实体添加主键
			modelBuilder.Entity<TestInfo>().HasKey(x => x.TestInfoId);
			// 给实体的字符串类型属性添加长度限制
			// .IsRequired()	是用来指定该属性在数据库中是必填的，不能为 null。
			// .HasMaxLength(50)	指定了该属性的最大长度是 50。
			modelBuilder.Entity<TestInfo>().Property(x => x.TestInfoName).IsRequired().HasMaxLength(50);

			base.OnModelCreating(modelBuilder);
		}
		/// <summary>
		/// 养殖列表
		/// </summary>
		public DbSet<Breeding> Breedings { get; set; }
		/// <summary>
		/// 养殖企业列表
		/// </summary>
		public DbSet<BreedingCompany> BreedingCompanies { get; set; }
		/// <summary>
		/// 深加工列表
		/// </summary>
		public DbSet<DeepProcessing> DeepProcessings { get; set; }
		/// <summary>
		/// 深加工企业列表
		/// </summary>
		public DbSet<DeepProcessingCompany> DeepProcessingCompanies { get; set; }
		/// <summary>
		/// 保健信息列表
		/// </summary>
		public DbSet<HealthInfo> HealthInfos { get; set; }
		/// <summary>
		/// 图片信息列表
		/// </summary>
		public DbSet<ImagePicture> ImagePictures { get; set; }
		/// <summary>
		/// 商品基础信息列表
		/// </summary>
		public DbSet<ProductBasics> ProductBasicses { get; set; }
		/// <summary>
		/// 商品名称列表
		/// </summary>
		public DbSet<ProductName> ProductNames { get; set; }
		/// <summary>
		/// 地点列表
		/// </summary>
		public DbSet<Place> Places { get; set; }
		/// <summary>
		/// 屠宰列表
		/// </summary>
		public DbSet<Slaughter> Slaughters { get; set; }
		/// <summary>
		/// 屠宰企业列表
		/// </summary>
		public DbSet<SlaughterCompany> SlaughterCompanies { get; set; }
		/// <summary>
		/// 供应商列表
		/// </summary>
		public DbSet<Supplier> Suppliers { get; set; }
		/// <summary>
		/// 权限列表
		/// </summary>
		public DbSet<Permission> Permissions { get; set; }
		/// <summary>
		/// 角色列表
		/// </summary>
		public DbSet<Role> Roles { get; set; }
		/// <summary>
		/// 角色权限列表
		/// </summary>
		public DbSet<RolePermission> RolePermissions { get; set; }
		/// <summary>
		/// 用户列表
		/// </summary>
		public DbSet<UserInfo> UserInfos { get; set; }
		/// <summary>
		/// 用户角色列表
		/// </summary>
		public DbSet<UserRole> UserRoles { get; set; }
		/// <summary>
		/// 按钮列表
		/// </summary>
		public DbSet<ButtonInfo> ButtonInfos { get; set; }
		/// <summary>
		/// 权限按钮列表
		/// </summary>
		public DbSet<PermissionButton> PermissionButtons { get; set; }
	}
}
